package com.chif.goingplus.controller;

import com.chif.goingplus.pojo.Option;
import com.chif.goingplus.pojo.Options;
import com.chif.goingplus.service.OptionService;
import com.chif.goingplus.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("/option")
public class OptionController {

    @Autowired
    OptionService optionService;


    @ResponseBody
    @RequestMapping("/getAllOption")
    public String getOption(){
        List<Option> origins = optionService.queryAllOrigin();
        List<Option> destinations = optionService.queryAllDestination();
        List<Option> emps = optionService.queryAllEmp();
        List<Option> status = optionService.queryAllStatus();
        List<Option> buses = optionService.queryAllBus();
        Options options = new Options(origins,destinations,emps,status,buses);
        //System.out.println(JsonUtils.getJson(options));
        return JsonUtils.getJson(options);
    }
}
